	<script>
		$(document).ready(function()
		{

			
			// Ajout dynamique de nouveau champs d'upload (inscription)
			$("button#add_field").click(function (){
			var nb = $('div.upload').length;
			
			if(nb < 5)
				$('div.upload:eq('+(nb-1)+')').after('<div class="control-group upload"><label class="control-label" for="avatar'+(nb+1)+'">Autre image</label><div class="controls"><input type="file" name="file_'+(nb+1)+'" id="avatar'+(nb+1)+'" /></div></div>');
			
			});
			
			
			
		});

		function searchLieu()
		{
			$.ajax({
      // have to use synchronous here, else the function 
      // will return before the data is fetched
      async: false,
      type:'POST',
      url: "<?php echo url('lieu/ajax_search_lieu'); ?>",
      data:"name="+$("#search_input").val(),
        
      success: function(data) {
        //alert(data);
        //data2 = eval ('('+data+')');
      	ret =data ;
      	$("#list-lieu").html(data);
        //alert(ret);
      }
    });
		}
	</script>
	<!-- Corps du site -->
    <section id="corps">
		<h1>Ajouter un nouvel évènement:</h1>
		<form class="form-horizontal" action="<?php echo url('event/add_validation'); ?>" method="post" accept-charset="utf-8" enctype="multipart/form-data">
				   <div class="control-group">
					<label class="control-label" for="type_event">Type de l'événement</label>
					<div class="controls">
						<select id="type_event" name="type_event">
							<?php 
							
							foreach ($list_event as $value)
							{ 
								echo '<option value="'.$value['id'].'">'.$value['nom'].'</option>';
							}
							?>
						</select>
					</div>
				   </div>
				   <div class="control-group">
					<label class="control-label" for="name_event">Nom de l'événement</label>
					<div class="controls">
						<input type="text" id="name_event" name="name_event" placeholder="Nom" value="" />
					</div>
				   </div>
				     <div class="control-group">
					<label class="control-label" for="desc_event">Description</label>
					<div class="controls">
						<textarea id="desc_event" name="desc_event" placeholder="Description"></textarea>
					</div>
				   </div>
				  <div class="control-group">
					<label class="control-label" for="lieu_event">Lieu</label>
					<div class="controls">
					  <div class="input-prepend">
  					<span class="add-on">Lieu</span>
  						<input class="span2" id="search_input" type="text" placeholder="Username" onkeyup="searchLieu();">
					</div>
					  <div id="list-lieu">
					  </div>
					</div>
				  </div>
				  <div class="control-group">
					<label class="control-label" for="icon_event">Image de présentation</label>
					<div class="controls">
					  <input type="file" name="icon_event" id="icon_event" placeholder="Icone" />
					</div>
				  </div>
				   <div class="control-group upload">
					<label class="control-label" for="other_image">Autre image</label>
					<div class="controls">
					  <input type="file" name="file_1" id="other_image" />
					  <button type="button" class="btn btn-mini btn-warning" id="add_field"><i class="icon-plus icon-white"></i></button>
					</div>
				  </div>
				   <div class="control-group">
					<div class="controls">
					  <button type="submit" class="btn btn-primary">Ajouter l'événement</button>
					</div>
				  </div>
				</form>
    </section>
